﻿#include <iostream>
#include <map>
using namespace std;
//map容器构造和赋值
void printMap(const map<int,int>& mp)
{
	for (map<int, int>::const_iterator it = mp.begin(); it != mp.end(); it++)
	{
		cout << it->first << "  " << it->second << "  " << endl;
	}
	cout << endl;
}
void test01()
{
	map<int, int> mp;
	mp.insert(pair<int, int>(3, 30));
	mp.insert(pair<int, int>(1, 10)); //pair这里是个匿名对组
	mp.insert(pair<int, int>(2, 20));
	mp.insert(pair<int, int>(4, 40));
	printMap(mp);
	//拷贝构造
	map<int, int>mp2(mp);
	printMap(mp2);
	//赋值
	map<int, int>m3;
	m3 = mp2;
	printMap(m3);
}
int main()
{
	test01();
}